﻿/*  PandoraUnleashed
    An open source API for the Pandora music service
    Copyright © 2011 Saulius Milevicius

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PandoraUnleashed.Data
{
    class AudioAdData : TrackData
    {
        public String adToken { get; set; }
        public ArrayList adTrackingTokens { get; set; }
        public String clickThroughUrl { get; set; }
        public AdData followOnBanner { get; set; }

        /// <summary>
        /// Audio Ad Data constructor
        /// </summary>
        /// <param name="stationId">Stations id in which ad appeared</param>
        /// <param name="adToken">Ads token</param>
        public AudioAdData(long stationId, String adToken)
            : base(stationId)
        {
            this.adToken = adToken;
        }

        /// <summary>
        /// Update the metadata of the audio ad
        /// </summary>
        /// <param name="json">Hashtable of json params</param>
        /// <param name="audioUrlMap">Audio url map</param>
        /// <param name="adData">Ad data</param>
        public void updateAdMetadata(Hashtable json, Dictionary<String, Dictionary<String, String>> audioUrlMap, AdData adData)
        {
            title = ((json.ContainsKey("title")) ? (String)json["title"] : "");
            creator = ((json.ContainsKey("companyName")) ? (String)json["companyName"] : "");
            artUrl = ((json.ContainsKey("imageUrl")) ? (String)json["imageUrl"] : "");
            clickThroughUrl = ((json.ContainsKey("clickThroughUrl")) ? (String)json["clickThroughUrl"] : "");
            adTrackingTokens = ((json.ContainsKey("adTrackingTokens")) ? (ArrayList)json["adTrackingTokens"] : null);
            trackGain = ((json.ContainsKey("trackGain")) ? (String)json["trackGain"] : "");
            followOnBanner = adData;
        }
    }
}
